import { Roles } from "src/roles/entities/role.entity";
import { Column, Entity, JoinTable, ManyToMany, PrimaryGeneratedColumn } from "typeorm";

@Entity('menus')
export class Menus {
    @PrimaryGeneratedColumn('uuid')
    id:string

    @Column({
        type:'varchar',
        length:50,
        comment:"菜单名"
    })
    name:string;

    @Column({
        type:'varchar',
        length:255,
        comment:"菜单路径"
    })
    path:string;
    
    @Column({
        type:'varchar',
        length:50,
        comment:"order"
    })
    order:number;

    @Column({
        type:'varchar',
        length:255,
        comment:"操作策略 create read update delete"
    })
    acl:string;


    // 和role表的关系是 多对多
    @ManyToMany(()=>Roles , (role)=> role.menus)
    @JoinTable({name:'roles_menus'})
    roles:Roles
}
